<template>
	<view class="swipermanagedetail">
		<view class="top">
			<image src='../../static/businessImg/back.png' class="topback" @click="back">
			</image>
			<view class="topname">
				店铺轮管理
			</view>
			
			<view class="chooseclick" >
				<span v-if="!status" @click="chooseclick">选择</span>
				<span v-else @click="deleteall">全部删除</span>
			</view>
		</view>
		
		<view class="swipermanagedetailcenter">
			<view class="swipermanagedetailcenterflexitem" v-for="(item, index) in list" :key="index">
				<image class="swipermanagedetailcenterpic1" :src="item.image"></image>
				<image  style="width: 28rpx; height: 28rpx;" v-if="status" src="../../static/businessImg/del.png" mode="" class="swipermanagedetailcenterpic2" @click="handleDeletepic(item)"></image>
			</view>
		</view>
		
		
		<u-modal v-model="show"  confirm-text="确认"  cancel-text="取消" title="是否删除所有轮播图"
			:show-cancel-button="true" width="618" :async-close="true" @confirm="confirm" :cancel-style="cancelstyleobj"
			:confirm-style="confirmstyleobj"  :title-style="titleObj">
			<view class="slot-content2">
				确定删除所有轮播图
			</view>
		</u-modal>
	</view>
</template>

<script>
	
	import storage from '@/utils/storage.js';
	import {
		storeBanner,
		delStoreBanner,
		delStoreAllBanner
	} from '@/api/storeAdmin.js'
	export default {
		data() {
			return {
				status: false,
				show: false,
				titleObj: {
					'font-family': 'Source Han Sans CN',
					'font-weight': '500',
					'font-size': '53rpx',
					color: '#151F38'
				},
				cancelstyleobj: {
					width: '260rpx',
					height: '77rpx',
					'border-radius': '35rpx',
					'line-height': '77rpx',
					color: '#ffffff',
					'text-align': 'center',
					'font-size': '28rpx',
					'background-color': 'rgb(216,216,216)'
				},
				confirmstyleobj: {
					width: '260rpx',
					height: '77rpx',
					'border-radius': '35rpx',
					'line-height': '77rpx',
					color: '#ffffff',
					'text-align': 'center',
					'font-size': '28rpx',
					'background-color': 'rgb(146,207,56)',
					'margin-left': '33rpx'
				},
				list: []
			}
		},
		
		onShow() {
			this.getBanner()
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			navigateTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			
			chooseclick(){
				this.status = true;
				
			},
			deleteall(){
				this.show = true
			},
			confirm(){
				this.show = false;
				delStoreAllBanner({
					id: storage.getUserInfo().storeId
				}).then(res => {
					uni.showToast({
						icon: 'none',
						title:'删除成功',
						duration: 2000
					});
					this.getBanner()
				})
			},
			getBanner(){
				storeBanner({
					id: storage.getUserInfo().storeId
				}).then(res => {
					this.list = res.data
				})
			},
			handleDeletepic(item){
				delStoreBanner({
					id: item.id
				}).then(res => {
					uni.showToast({
						icon: 'none',
						title: '删除成功'
					});
					
					this.getBanner()
				})
			}
		}
	}
</script>

<style scoped>
	.swipermanagedetail {
		width: 100%;
		min-height: 100vh;
	}

	.top {
		width: 100%;
		height: 188rpx;
		position: relative;
		background: #FFFFFF;
	}

	.topback {
		width: 16rpx;
		height: 29rpx;
		position: absolute;
		top: 106rpx;
		left: 32rpx;
	}

	.topname {
		width: 300rpx;
		height: 32rpx;
		text-align: center;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		font-size: 33rpx;
		color: #222222;
		line-height: 32rpx;
		position: absolute;
		top: 104rpx;
		left: 50%;
		transform: translateX(-50%);
	}
	
	.chooseclick {
		font-family: Adobe Heiti Std;
		font-weight: normal;
		font-size: 29rpx;
		color: #222222;
		position: absolute;
		top: 104rpx;
		right: 27rpx;
	}
	
	.swipermanagedetailcenter {
		width: 100%;
		padding: 0 25rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-content: flex-start;
	}
	
	.swipermanagedetailcenterflexitem {
		width: 100%;
		height: 373rpx;
		margin-top: 43rpx;
		position: relative;
		
		.swipermanagedetailcenterpic1 {
			width: 100%;
			height: 100%;
		}
		
		.swipermanagedetailcenterpic2 {
			width: 28rpx;
			height: 28rpx;
			position: absolute;
			top: -14rpx;
			right: -14rpx;
		}
	}
	
	.slot-content2 {
		height: 145rpx;
		line-height: 145rpx;
		text-align: center;
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 38rpx;
		color: #707070;
	}
	
	
	::v-deep .u-model__footer {
		justify-content: space-around;
		/* padding-bottom: 20rpx; */
		height: 100rpx;
		align-items: center;
	}
</style>
